home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
truetype
/
datasht.zip
/
README.TXT
< prev
next >
Wrap
Text File
|
1993-04-25
|
9KB
|
191 lines
DATASHT.DOT -- An interactive form by John Hill
The macros in DATASHT.DOT illustrate features that make an interactive form
with many fields a pleasure to use. This example is a single page datasheet
with 82 fields. By using FieldChars instead of bookmarks, the limit of 2000
fields is exploited to allow up to 24 completed datasheets in a single
document (82 x 24 = 1968). Dials are provided to allow the user to jump
directly to any desired datasheet and field. An option is provided to
extract data from previously created .TXT files. All fields are length
checked.
Viewing the macros:
DATASHT.DOT includes an AutoOpen macro that doesn't provide the option to
edit the macros (this is intentional). There is a back door, however. After
loading Word, select FileTemplate and attach DATASHT.DOT. DATASHT.DOT must
be in the "programdir" or "DOT-PATH" listed in the [Microsoft Word 2.0]
section of your WIN.INI file or in the current directory.
Now you can use ToolsMacro to View (Edit) the macros. Select the Show
Template Macros option if it isn't already selected.
The following macros will be listed:
AutoNew
AutoOpen
CreateDataSheet
Echo
FillinManually
InsertFieldLocationData
LoadSheetsFromTextFile
MoreInformation
The following are brief descriptions of the macros:
AutoNew:
Maximizes the document window, adjusts the view so that the width of the form
is visible and so that the form appears as it will when printed and presents
the "Data Sheet Main Menu" dialog box. The Echo macro is used to prevent the
user from seeing the activity before the menu is presented. The Data Sheet
Main Menu items and actions are as follows:
ITEM ACTION
Print a Blank Data Sheet Runs CreateDataSheet, prints the
datasheet and then deletes it.
Fillin or Edit Data Sheets Runs FillinManually
Create Data Sheets From Text File Runs LoadSheetsFromTxtFile
Print Data Sheets Runs FilePrint
More Information Runs MoreInformation
Exit Runs FileClose and Exits the
document
AutoOpen:
Runs AutoNew
CreateDataSheet:
If the subroutine CreateDataSheet(CopyLast) is called, a blank datasheet is
created if the argument 0 is passed or the last datasheet is copied if the
argument 1 is passed. A blank datasheet is created if CreateDataSheet is
called directly.
A blank datasheet is created by inserting it from the glossary. The blank
datasheet includes FieldChars in each of the 82 fields. The user is
requested to "PLEASE BE PATIENT" because of the time required to perform the
following operations:
1. Repaginate the document to update the page count.
2. Toggle the Field Display to hide the FieldChars.
The subroutine Echo(n) is used to hide the above activity from the user and
speed-up operation.
Echo:
This macro is contained in the file VGECHO.EXE available in Lib 2 of the
PROGMSA forum. If the subroutine Echo(n) is called, document window updating
is suspended if the argument 0 is passed, Word application window updating is
suspended if the argument -1 is passed or updating is resumed if the argument
0 is passed. If Echo is called directly, updating is resumed.
FillinManually:
This macro is the heart of DATASHT.DOT. It's built around a For..Next loop
that presents the "Data Sheet Navigation" dialog box and is incremented if
the "Next Field" button or Enter is depressed or is decremented if the "Prev
Field" button is depressed. Each time the loop is incremented or
decremented, the cursor is positioned in the next or previous field.
The first line of Sub MAIN calls subroutine LoadFieldTable, immediately
following Sub MAIN. Subroutine LoadFieldTable loads arrays that contain the
name, length, prompt and position of each of the 82 fields.
The "GoTo:" dialog box is presented if the "Cancel" button on the "Data Sheet
Navigation" dialog box is depressed. The "GoTo: dialog box is similar to the
dialog box that is presented by the Edit Go To command except that the option
to go directly to another page (datasheet in this case) is also provided.
When a new field is selected, the cursor is first moved to the line the field
is on and then incremented the required number fields to the right, instead
of jumping directly to a bookmark as would be done if bookmarks were used.
Unlike bookmarks, the use of FieldChars allows the same names to be used
regardless of page. The ability to jump directly to a field up to 2000
fields away is unique to this method. The only difference if another page is
selected is that the cursor is first positioned at the beginning of the first
line of the datasheet on the new page.
InsertFieldLocationData:
This macro was used create the lines necessary to load arrays LineNo() and
FieldsRight() in macro "FillinManually". It first determines the values of
LineNo(n) and FieldsRight(n) for each field in the datasheet and then inserts
the lines necessary to load these arrays at the end of the current document.
Use the following procedure to give it a try:
1. Follow the procedure in "Viewing the macros:"
2. Use "ToolsMacro" to run "CreateDataSheet" to create a blank datasheet.
3. Use "ToolsMacro" to run "InsertFieldLocationData".
The results obtained were cut from the document, pasted to the end of macro
"FillinManually" and edited to the present form. The same macro may be used
to do the same for ANY form with fields. Simply replace 82 where ever it
appears with the number of fields in YOUR form.
CAUTION: If your form contains table rows that are less than the normal
height, some values of LineNo() may need to be changed. This was the case
with the datasheet in DATASHT.DOT. Apparently, there are two line counts:
the one created when a document is Paginated and that is listed in the status
bar and read by SelInfo(10) and the one used by the EditGoTo command. They
are NOT always the same.
LoadSheetsFromTxtFile:
The datasheet in DATASHT.DOT is based on an existing WordPerfect 5.1 form
used extensively in the past. Hundreds of WordPerfect 5.1 documents exist
that contain several pages of text followed by completed datasheets.
"LoadSheetsFromTxtFile" was written in case there is ever a desire to create
new Word datasheets from old WordPerfect 5.1 datasheets. It is much faster
to extract data from a file directly than to insert the file and copy the
information from one location to another as was done in earlier versions of
the macro. First the file containing the desired datasheets must be opened
in WordPerfect and the desired datasheets selected and saved in a Text file.
The procedure is in macro "MoreInformation" and may be printed. Saving the
desired datasheets in a Text file places a carriage return and line feed at
the end of each line and removes all formatting information so that the
WordBasic string functions may be used to locate the data in the old
datasheets based on a knowledge of the position and length of the desired
data in a line.
The InsertFile dialog box is used to obtain the name of the text file. The
subroutine Echo(n) is used to hide uninteresting activity from the user and
speed-up operation.
Subroutine LocateNextLine(Text$, CR) is used to place the contents of a
desired line, located using the value of Text$, in Line$ and set CurPos at
the location of the data or at the beginning of the next line. The syntax is
explained in detail in the macro. An error code is returned if the file
opened is not a text file.
Text$ is replaced with the desired data from Line$ using the WordBasic Mid$()
function and the value of CurPos.
Subroutine CopyToNextField positions the cursor at the next field in the new
Word datasheet, selects the current contents of the field and inserts Text$
in its place. The syntax is explained in detail in the macro.
MoreInformation:
The starting point for macro "MoreInformation" was the "Instructions" macro
in LETMODBK.DOT, variations of which are also found in LETBLOCK.DOT,
LETMDSEM.DOT and LETPERSN.DOT. The only added touch is the ability to print
the procedure listed for creating Text files from datasheets contained in
WP51 documents.
The reason it was necessary to include a copy of Subroutine Echo(n) is that
the lines to be printed are inserted into a "FileNewDefault", based on
NORMAL.DOT, which may not include a copy of macro Echo.
Questions of Comments:
Please feel free to address questions or comments to John Hill, 73567,2054,
in Section 2 of the PROGMSA CompuServe forum.